<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>总部</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<script src="${pageContext.request.contextPath}/js/MD5.js"></script>

</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>提现设置</span>
					</div>
					<form class="form-horizontal" style="margin-top: 60px">
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">每超市提现额度
							</label>
							<div class="col-xs-3">
								<input type="number" id="superSet"
									oninput="if(value.length>5)value=value.slice(0,5)"
									class="form-control" placeholder="请输入超市提现额度">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">县代理提现额度</label>
							<div class="col-xs-3">
								<input type="number" " id="agentSet"
									oninput="if(value.length>6)value=value.slice(0,6)"
									class="form-control" placeholder="请输入县代理提现额度">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">异业商家提现额度</label>
							<div class="col-xs-3">
								<input type="number" " id="otherSet"
									oninput="if(value.length>6)value=value.slice(0,6)"
									class="form-control" placeholder="请输入异业商家提现额度">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">直营商家提现额度</label>
							<div class="col-xs-3">
								<input type="number" " id="directSet"
									oninput="if(value.length>6)value=value.slice(0,6)"
									class="form-control" placeholder="请输入直营商家提现额度">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">秒杀广告费用</label>
							<div class="col-xs-3">
								<input type="number" " id="adRate"
									oninput="if(value.length>6)value=value.slice(0,6)"
									class="form-control" placeholder="请输入秒杀广告费用">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">提现手续费千分之</label>
							<div class="col-xs-3">
								<input type="number" id="feeSet"
									oninput="if(value.length>2)value=value.slice(0,2)"
									class="form-control" placeholder="请输入提现手续费">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label" style="text-align: right">退货返现</label>
							<div class="col-xs-3">
								<input type="number" id="returnSet"
									oninput="if(value.length>3)value=value.slice(0,3)"
									class="form-control" placeholder="请输入退货返现百分比">
							</div>
						</div>
						<div class="form-group">
							<div class="col-xs-4 col-xs-offset-2">
								<button type="button" class="col-xs-6 btn btn-primary"
									onclick="submitSet()">点此设置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
	<script>
		$(function() {
			$.post(urls + "headAction/selectHeadWithdarw",
				function(res) {
					if (res) {
						$("#superSet").val(res.superWithdraw);
						$("#agentSet").val(res.agentWithdraw);
						$("#feeSet").val(res.withdrawPoundage);
						$("#returnSet").val(res.returnPoundage);
						$("#adRate").val(res.adRate);
						$("#otherSet").val(res.otherWithdraw);
						$("#directSet").val(res.dricetWithdraw);
						
					}
				}
			)
		})
		function submitSet() {
			var superSet = $("#superSet").val();
			var agentSet = $("#agentSet").val();
			var feeSet = $("#feeSet").val();
			var adRate = $("#adRate").val();
			var otherSet = $("#otherSet").val();
			var directSet=$("#directSet").val();
			var returnSet = $("#returnSet").val();
			if (feeSet && agentSet && superSet && returnSet) {
				$.post(urls + "headAction/updateHeadWithdarw",
					{
					    id:1,
	                    superWithdraw:superSet,
	                    agentWithdraw:agentSet,
	                    withdrawPoundage:feeSet,
	                    returnPoundage:returnSet,
	                    adRate:adRate,
	                    otherWithdraw:otherSet,
	                    dricetWithdraw:directSet
					},
					function(data) {
						if (data) {
							alert("设置成功");
						} else {
							alert("设置失败")
						}
					})
			} else {
				alert("请填写完整信息")
			}
		}
	</script>
</body>
</html>